<%@ tag import="com.eischet.lookup.web.SearchableCategory" %>
<%@ tag import="com.eischet.lookup.web.SearchableType" %>
<%@ attribute name="name" %>
<%@ attribute name="searchIndex" type="com.eischet.lookup.web.SearchIndex" required="true" %>
<%@ attribute name="selectedType" type="java.lang.String" required="true" %>

<select name="t" style="display:inline;">
    <option value="any">Anything</option>
    <% for (SearchableCategory category: searchIndex.getSearchableCategories()) { %>
        <optgroup label="<%=category.getTitle()%>">
            <% if (category.isSelectable()) { %>
                <% if (selectedType.equalsIgnoreCase(category.getName())) { %>
                    <option selected="selected" value="<%= category.getName()%>"><%=category.getSelectionTitle()%></option>
                <% } else { %>
                    <option value="<%= category.getName()%>"><%=category.getSelectionTitle()%></option>
                <% } %>
            <% } %>
            <% for (SearchableType searchableType: category.getSearchableTypes()) { %>
                <% if (selectedType.equalsIgnoreCase(searchableType.getName())) { %>
                    <option selected="selected" value="<%= searchableType.getName()%>"><%=searchableType.getTitle()%></option>
                <% } else { %>
                    <option value="<%= searchableType.getName()%>"><%=searchableType.getTitle()%></option>
                <% } %>
            <% } %>
        </optgroup>
    <% } %>
</select>
